home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / CEGUISDK-0.4.1-VC6-Native.exe / {app} / include / renderers / directx9GUIRenderer / d3d9texture.h < prev   
Encoding:
C/C++ Source or Header  |  2005-02-16  |  6.2 KB  |  194 lines

  1. /************************************************************************
  2.     filename:     d3d9texture.h
  3.     created:    17/7/2004
  4.     author:        Paul D Turner with D3D 9 Updates by Magnus â•“sterlind
  5.     
  6.     purpose:    Defines concrete texture class for D3D9.0
  7. *************************************************************************/
  8. /*************************************************************************
  9.     Crazy Eddie's GUI System (http://www.cegui.org.uk)
  10.     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
  11.  
  12.     This library is free software; you can redistribute it and/or
  13.     modify it under the terms of the GNU Lesser General Public
  14.     License as published by the Free Software Foundation; either
  15.     version 2.1 of the License, or (at your option) any later version.
  16.  
  17.     This library is distributed in the hope that it will be useful,
  18.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20.     Lesser General Public License for more details.
  21.  
  22.     You should have received a copy of the GNU Lesser General Public
  23.     License along with this library; if not, write to the Free Software
  24.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  25. *************************************************************************/
  26. #ifndef _d3d9texture_h_
  27. #define _d3d9texture_h_
  28.  
  29. #include "CEGUIBase.h"
  30. #include "CEGUIRenderer.h"
  31. #include "CEGUITexture.h"
  32. #include "d3d9renderer.h"
  33. #include <d3d9.h>
  34. #include <list>
  35.  
  36. // Start of CEGUI namespace section
  37. namespace CEGUI
  38. {
  39.  
  40. /*!
  41. \brief
  42.     Texture class that is created by DirectX9Renderer objects
  43. */
  44. class DIRECTX9_GUIRENDERER_API DirectX9Texture : public Texture
  45. {
  46. private:
  47.     /*************************************************************************
  48.         Friends (to allow construction and destruction)
  49.     *************************************************************************/
  50.     friend    Texture* DirectX9Renderer::createTexture(void);
  51.     friend    Texture* DirectX9Renderer::createTexture(const String& filename, const String& resourceGroup);
  52.     friend    Texture* DirectX9Renderer::createTexture(float size);
  53.     friend    void     DirectX9Renderer::destroyTexture(Texture* texture);
  54.  
  55.  
  56.     /*************************************************************************
  57.         Construction & Destruction (by Renderer object only)
  58.     *************************************************************************/
  59.     DirectX9Texture(Renderer* owner);
  60.     virtual ~DirectX9Texture(void);
  61.  
  62. public:
  63.     /*!
  64.     \brief
  65.         Returns the current pixel width of the texture
  66.  
  67.     \return
  68.         ushort value that is the current width of the texture in pixels
  69.     */
  70.     virtual    ushort    getWidth(void) const        {return d_width;}
  71.  
  72.  
  73.     /*!
  74.     \brief
  75.         Returns the current pixel height of the texture
  76.  
  77.     \return
  78.         ushort value that is the current height of the texture in pixels
  79.     */
  80.     virtual    ushort    getHeight(void) const        {return d_height;}
  81.  
  82.  
  83.     /*!
  84.     \brief
  85.         Loads the specified image file into the texture.  The texture is resized as required to hold the image.
  86.  
  87.     \param filename
  88.         The filename of the image file that is to be loaded into the texture
  89.  
  90.     \param resourceGroup
  91.         Resource group identifier passed to the resource provider.
  92.  
  93.     \return
  94.         Nothing.
  95.     */
  96.     virtual void    loadFromFile(const String& filename, const String& resourceGroup);
  97.  
  98.  
  99.     /*!
  100.     \brief
  101.         Loads (copies) an image in memory into the texture.  The texture is resized as required to hold the image.
  102.  
  103.     \param buffPtr
  104.         Pointer to the buffer containing the image data
  105.  
  106.     \param buffWidth
  107.         Width of the buffer (in 0xAARRGGBB pixels)
  108.  
  109.     \param buffHeight
  110.         Height of the buffer (in 0xAARRGGBB pixels)
  111.  
  112.     \return
  113.         Nothing.
  114.     */
  115.     virtual void    loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight);
  116.  
  117.  
  118.     /*!
  119.     \brief
  120.         Return a pointer to the internal Direct3DTexture9 object
  121.  
  122.     \return
  123.         Pointer to the IDirect3DTexture9 interface currently being used by this Texture object
  124.     */
  125.     LPDIRECT3DTEXTURE9    getD3DTexture(void) const        {return d_d3dtexture;}
  126.  
  127.  
  128.     // 
  129.     /*!
  130.     \brief
  131.         set the size of the internal D3D texture.  Previous D3D texture is lost.
  132.  
  133.     \param size
  134.         pixel size of the new internal texture.  This will be rounded up to a power of 2.
  135.  
  136.     \return
  137.         Nothing.
  138.     */
  139.     void    setD3DTextureSize(uint size);
  140.  
  141.  
  142.     /*!
  143.     \brief
  144.         Direct3D support method that must be called prior to a Reset call on the
  145.         Direct3DDevice; this is required so that the GUI renderer can release any
  146.         unmanaged D3D resources as needed for the device reset to succeed.
  147.  
  148.     \note
  149.         You do not need to call this on DirectX9Texture objects created via the
  150.         DirectX9Renderer object; for such textures the method is called by the
  151.         system when you call the DirectX9Renderer::preD3DReset method.
  152.     */
  153.     virtual    void    preD3DReset(void);
  154.  
  155.  
  156.     /*!
  157.     \brief
  158.         Direct3D support method that must be called after a Reset call on the
  159.         Direct3DDevice; this is required so that the GUI renderer can rebuild any
  160.         unmanaged D3D resources after the device has been reset.
  161.  
  162.     \note
  163.         You do not need to call this on DirectX9Texture objects created via the
  164.         DirectX9Renderer object; for such textures the method is called by the
  165.         system when you call the DirectX9Renderer::postD3DReset method.
  166.     */
  167.     virtual    void    postD3DReset(void);
  168.  
  169.  
  170. private:
  171.     /*************************************************************************
  172.         Implementation Functions
  173.     *************************************************************************/
  174.     // safely free direc3d texture (can be called multiple times with no ill effect)
  175.     void    freeD3DTexture(void);
  176.  
  177.  
  178.     /*************************************************************************
  179.         Implementation Data
  180.     *************************************************************************/
  181.     LPDIRECT3DTEXTURE9        d_d3dtexture;        //!< The 'real' texture.
  182.     String                    d_filename;            //!< name of file used to create the texture, if any.
  183.     String                  d_resourceGroup;    //!< Group from which the file was loaded.
  184.     bool                    d_isMemoryTexture;    //!< true if the texture was created from memory (and not a file).
  185.  
  186.     ushort                    d_width;            //!< cached width of the texture
  187.     ushort                    d_height;            //!< cached height of the texture
  188. };
  189.  
  190. } // End of  CEGUI namespace section
  191.  
  192.  
  193. #endif    // end of guard _d3d9texture_h_
  194.